with Interfaces.C; use Interfaces.C;
with System;
--limited with stdio_h;
with SDL_stdinc_h;
with Interfaces.C.Strings;

package SDL_rwops_h is

   type u_iobuf is record
      u_ptr : Interfaces.C.Strings.chars_ptr;  -- c:\gnat\2009\bin\../lib/gcc/i686-pc-mingw32/4.3.4/../../../../i686-pc-mingw32/include/stdio.h:140:8
      u_cnt : aliased int;  -- c:\gnat\2009\bin\../lib/gcc/i686-pc-mingw32/4.3.4/../../../../i686-pc-mingw32/include/stdio.h:141:6
      u_base : Interfaces.C.Strings.chars_ptr;  -- c:\gnat\2009\bin\../lib/gcc/i686-pc-mingw32/4.3.4/../../../../i686-pc-mingw32/include/stdio.h:142:8
      u_flag : aliased int;  -- c:\gnat\2009\bin\../lib/gcc/i686-pc-mingw32/4.3.4/../../../../i686-pc-mingw32/include/stdio.h:143:6
      u_file : aliased int;  -- c:\gnat\2009\bin\../lib/gcc/i686-pc-mingw32/4.3.4/../../../../i686-pc-mingw32/include/stdio.h:144:6
      u_charbuf : aliased int;  -- c:\gnat\2009\bin\../lib/gcc/i686-pc-mingw32/4.3.4/../../../../i686-pc-mingw32/include/stdio.h:145:6
      u_bufsiz : aliased int;  -- c:\gnat\2009\bin\../lib/gcc/i686-pc-mingw32/4.3.4/../../../../i686-pc-mingw32/include/stdio.h:146:6
      u_tmpfname : Interfaces.C.Strings.chars_ptr;  -- c:\gnat\2009\bin\../lib/gcc/i686-pc-mingw32/4.3.4/../../../../i686-pc-mingw32/include/stdio.h:147:8
   end record;
   pragma Convention (C, u_iobuf);  -- c:\gnat\2009\bin\../lib/gcc/i686-pc-mingw32/4.3.4/../../../../i686-pc-mingw32/include/stdio.h:139:1

  RW_SEEK_SET : constant := 0;  --  SDL_rwops.h:109
  RW_SEEK_CUR : constant := 1;  --  SDL_rwops.h:110
  RW_SEEK_END : constant := 2;  --  SDL_rwops.h:111
  --  arg-macro: function SDL_RWseek (ctx, offset, whence)
  --    return ctx).seek(ctx, offset, whence;
  --  arg-macro: function SDL_RWtell (ctx)
  --    return ctx).seek(ctx, 0, RW_SEEK_CUR;
  --  arg-macro: function SDL_RWread (ctx, ptr, size, n)
  --    return ctx).read(ctx, ptr, size, n;
  --  arg-macro: function SDL_RWwrite (ctx, ptr, size, n)
  --    return ctx).write(ctx, ptr, size, n;
  --  arg-macro: function SDL_RWclose (ctx)
  --    return ctx).close(ctx;


  --

  -- This file provides a general interface for SDL to read and write
  --   data sources.  It can easily be extended to files, memory, etc.
  --

  -- Set up for C function definitions, even when using C++
  -- This is the read/write operation structure -- very basic
  -- Seek to 'offset' relative to whence, one of stdio's whence values:
  --		SEEK_SET, SEEK_CUR, SEEK_END
  --	   Returns the final offset in the data source.
  --

   type anon_8;
   type anon_9;
   type anon_10 is record
      data : System.Address;  -- SDL_rwops.h:70:13
      size : aliased int;  -- SDL_rwops.h:71:11
      left : aliased int;  -- SDL_rwops.h:72:11
   end record;
   pragma Convention (C, anon_10);
   type anon_9 is record
      append : aliased int;  -- SDL_rwops.h:67:9
      h : System.Address;  -- SDL_rwops.h:68:9
      buffer : aliased anon_10;  -- SDL_rwops.h:73:5
   end record;
   pragma Convention (C, anon_9);
   type anon_11 is record
      autoclose : aliased int;  -- SDL_rwops.h:78:7
      fp : access u_iobuf;  -- SDL_rwops.h:79:10
   end record;
   pragma Convention (C, anon_11);
   type anon_12 is record
      base : access SDL_stdinc_h.Uint8;  -- SDL_rwops.h:83:10
      here : access SDL_stdinc_h.Uint8;  -- SDL_rwops.h:84:11
      stop : access SDL_stdinc_h.Uint8;  -- SDL_rwops.h:85:10
   end record;
   pragma Convention (C, anon_12);
   type anon_13 is record
      data1 : System.Address;  -- SDL_rwops.h:88:9
   end record;
   pragma Convention (C, anon_13);
   type anon_8 (discr : unsigned := 0) is record
      case discr is
         when 0 =>
         win32io : aliased anon_9;  -- SDL_rwops.h:74:8
         when 1 =>
         stdio : aliased anon_11;  -- SDL_rwops.h:80:8
         when 2 =>
         mem : aliased anon_12;  -- SDL_rwops.h:86:8
         when others =>
         unknown : aliased anon_13;  -- SDL_rwops.h:89:8
      end case;
   end record;
   pragma Convention (C, anon_8);
   pragma Unchecked_Union (anon_8);
   type SDL_RWops is record
      seek : access function
           (arg1 : access SDL_RWops;
            arg2 : int;
            arg3 : int) return int;  -- SDL_rwops.h:46:71
      read : access function
           (arg1 : access SDL_RWops;
            arg2 : System.Address;
            arg3 : int;
            arg4 : int) return int;  -- SDL_rwops.h:52:80
      write : access function
           (arg1 : access SDL_RWops;
            arg2 : System.Address;
            arg3 : int;
            arg4 : int) return int;  -- SDL_rwops.h:58:84
      close : access function (arg1 : access SDL_RWops) return int;  -- SDL_rwops.h:61:48
      c_type : aliased SDL_stdinc_h.Uint32;  -- SDL_rwops.h:63:9
      hidden : aliased anon_8;  -- SDL_rwops.h:90:4
   end record;
   pragma Convention (C, SDL_RWops);  -- SDL_rwops.h:41:26

  -- Read up to 'num' objects each of size 'objsize' from the data
  --	   source to the area pointed at by 'ptr'.
  --	   Returns the number of objects read, or -1 if the read failed.
  --

  -- Write exactly 'num' objects each of size 'objsize' from the area
  --	   pointed at by 'ptr' to data source.
  --	   Returns 'num', or -1 if the write failed.
  --

  -- Close and free an allocated SDL_FSops structure
  -- Functions to create SDL_RWops structures from various data sources
   function SDL_RWFromFile (file : Interfaces.C.Strings.chars_ptr; mode : Interfaces.C.Strings.chars_ptr) return access SDL_RWops;  -- SDL_rwops.h:97:86
   pragma Import (C, SDL_RWFromFile, "SDL_RWFromFile");

   function SDL_RWFromFP (fp : access u_iobuf; autoclose : int) return access SDL_RWops;  -- SDL_rwops.h:100:73
   pragma Import (C, SDL_RWFromFP, "SDL_RWFromFP");

   function SDL_RWFromMem (mem : System.Address; size : int) return access SDL_RWops;  -- SDL_rwops.h:103:70
   pragma Import (C, SDL_RWFromMem, "SDL_RWFromMem");

   function SDL_RWFromConstMem (mem : System.Address; size : int) return access SDL_RWops;  -- SDL_rwops.h:104:81
   pragma Import (C, SDL_RWFromConstMem, "SDL_RWFromConstMem");

   function SDL_AllocRW return access SDL_RWops;  -- SDL_rwops.h:106:53
   pragma Import (C, SDL_AllocRW, "SDL_AllocRW");

   procedure SDL_FreeRW (area : access SDL_RWops);  -- SDL_rwops.h:107:56
   pragma Import (C, SDL_FreeRW, "SDL_FreeRW");

  -- Macros to easily read and write from an SDL_RWops structure
  -- Read an item of the specified endianness and return in native format
   function SDL_ReadLE16 (src : access SDL_RWops) return SDL_stdinc_h.Uint16;  -- SDL_rwops.h:122:59
   pragma Import (C, SDL_ReadLE16, "SDL_ReadLE16");

   function SDL_ReadBE16 (src : access SDL_RWops) return SDL_stdinc_h.Uint16;  -- SDL_rwops.h:123:59
   pragma Import (C, SDL_ReadBE16, "SDL_ReadBE16");

   function SDL_ReadLE32 (src : access SDL_RWops) return SDL_stdinc_h.Uint32;  -- SDL_rwops.h:124:59
   pragma Import (C, SDL_ReadLE32, "SDL_ReadLE32");

   function SDL_ReadBE32 (src : access SDL_RWops) return SDL_stdinc_h.Uint32;  -- SDL_rwops.h:125:59
   pragma Import (C, SDL_ReadBE32, "SDL_ReadBE32");

   function SDL_ReadLE64 (src : access SDL_RWops) return SDL_stdinc_h.Uint64;  -- SDL_rwops.h:126:59
   pragma Import (C, SDL_ReadLE64, "SDL_ReadLE64");

   function SDL_ReadBE64 (src : access SDL_RWops) return SDL_stdinc_h.Uint64;  -- SDL_rwops.h:127:59
   pragma Import (C, SDL_ReadBE64, "SDL_ReadBE64");

  -- Write an item of native format to the specified endianness
   function SDL_WriteLE16 (dst : access SDL_RWops; value : SDL_stdinc_h.Uint16) return int;  -- SDL_rwops.h:130:71
   pragma Import (C, SDL_WriteLE16, "SDL_WriteLE16");

   function SDL_WriteBE16 (dst : access SDL_RWops; value : SDL_stdinc_h.Uint16) return int;  -- SDL_rwops.h:131:71
   pragma Import (C, SDL_WriteBE16, "SDL_WriteBE16");

   function SDL_WriteLE32 (dst : access SDL_RWops; value : SDL_stdinc_h.Uint32) return int;  -- SDL_rwops.h:132:71
   pragma Import (C, SDL_WriteLE32, "SDL_WriteLE32");

   function SDL_WriteBE32 (dst : access SDL_RWops; value : SDL_stdinc_h.Uint32) return int;  -- SDL_rwops.h:133:71
   pragma Import (C, SDL_WriteBE32, "SDL_WriteBE32");

   function SDL_WriteLE64 (dst : access SDL_RWops; value : SDL_stdinc_h.Uint64) return int;  -- SDL_rwops.h:134:71
   pragma Import (C, SDL_WriteLE64, "SDL_WriteLE64");

   function SDL_WriteBE64 (dst : access SDL_RWops; value : SDL_stdinc_h.Uint64) return int;  -- SDL_rwops.h:135:71
   pragma Import (C, SDL_WriteBE64, "SDL_WriteBE64");

  -- Ends C function definitions when using C++
end SDL_rwops_h;
